package com.hwadee.backend.entity.HealthRecord;

import lombok.Getter;
import lombok.Setter;

import java.sql.Date;

@Setter
@Getter
public class PastMedicalHistory extends HealthRecord {
    // 疾病名称
    private String diseaseName;
    // 症状
    private String symptoms;
    // 病因
    private String cause;
    // 治疗过程
    private String treatmentProcess;
    // 是否有后遗症
    private String hasSequel;
    // 备注
    private String remarks;

    public PastMedicalHistory() {}

    public PastMedicalHistory(int recordId, Date recordDate, String recordType, String detail) {
        super(recordId, recordDate, recordType, detail);
        splitDetail(detail);
        super.setDetail(null); // 将 detail 置为空值
    }

    /**
     * 从 detail 字符串中解析疾病名称、症状、病因、治疗过程、是否有后遗症和备注
     * @param detail 包含疾病名称、症状、病因、治疗过程、是否有后遗症和备注的字符串，用 | 分隔
     */
    private void splitDetail(String detail) {
        String[] parts = detail.split("\\|");
        if (parts.length >= 1) {
            this.diseaseName = parts[0];
        }
        if (parts.length >= 2) {
            this.symptoms = parts[1];
        }
        if (parts.length >= 3) {
            this.cause = parts[2];
        }
        if (parts.length >= 4) {
            this.treatmentProcess = parts[3];
        }
        if (parts.length >= 5) {
            this.hasSequel = parts[4];
        }
        if (parts.length >= 6) {
            this.remarks = parts[5];
        }
    }

}